<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr=new Array(30)
        var avg
        var arr1=[]
        for(var i=0; i<=arr.length;i++){
            if(i<arr.length){

          
                arr[i]=i*2+2
            }
                if(i % 5==0 && i!=2 && i!=0){
                    avg=(arr[i-1]+arr[i-2]+arr[i-3]+arr[i-4]+arr[i-5])/5
                    console.log(avg)
                    arr1.push(avg)
                }
        }
        
        console.log(arr)
        console.log(arr1)
    </script>
</body>
</html>